import requests
import bs4

def open_url(url):
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
    }
    res = requests.get(url, headers=headers)
    return res


def main():
    res = open_url("https://tb.rg-adguard.net/dump.php?p=2&seach=Win10_%_Chinese(Simplified)_x64.iso&str=100&lang=zh-CN")
    soup = bs4.BeautifulSoup(res.text, "html.parser")
    table = soup.find_all("table", class_="tftable")
    targets = table[0].find_all("tr")

    for item in targets:
        td = item.find_all("td")
        try:
            print("\n")
            # 名称
            print("系统名称：" + td[0].get_text())
            # 大小
            print("系统大小：" + td[2].get_text())
            # 下载链接
            print("下载链接：" +  td[3].a['href'])
        except Exception:
            continue

if __name__ == "__main__":
    main()
